#ifndef __OBJECTSCENEMANAGER_H__
#define __OBJECTSCENEMANAGER_H__

#include <AGTRenderSystem/RenderManager.h>
#include "Object.h"
#include "ObjectScene.h"
#include "Component.h"
#include <vector>
#include <string>

using namespace std;



//====================================================================================== OBJECT SCENE MANAGER

/*
	Creates viewport and camera settings for the game.
	Manages all the scenes and the player object.
	The player object is managed so that the player object can be moved from one scene to another.
*/

class ObjectScene;
class ObjectSceneManager : public Ogre::FrameListener
{
private:	// Attributes
	vector<ObjectScene*>					m_Scenes;					// Store of scenes
	vector<ObjectScene*>::iterator			it;							// Vector iterator
	ObjectScene								*m_pCurrentScene;			// A pointer to the current scene
	ObjectScene								*m_pPrevScene;				// Previous scene pointer

	static ObjectSceneManager				*objSceneMgr;				// For singleton purposes

	/*
		Ogre scene manager is first created by
	*/
	Ogre::SceneManager						*m_pSceneMgr;				// Ogre scene manager
	Ogre::Camera							*m_pCamera;					// Ogre camera object
	Ogre::Viewport							*m_pViewport;				// Window view port
private:	// Functions
	ObjectSceneManager();	// Creates a default scene in order to set up a 

	void setCameraViewport();
public:
	static ObjectSceneManager* getSingleton();
	~ObjectSceneManager();

	//void createScene(string scene_name);
	bool ManageScene(ObjectScene* scene);						// Adds scene to storage
	void switchToScene(string scene_name, Object* playerObj);
	ObjectScene* getScene(string scene_name);
	void addObjectToScene(string scene_name, Object* obj);
	void removeObjectFromScene(ObjectScene *scene);

	ObjectScene* getSceneOfObject(Object *obj);	// Return the scene in which the object is in.

	bool isInStore(string scene_name);

	Ogre::Camera* getCamera(void){ return m_pCamera; };

	// Updates the current scene.
	void updateScene();

	// Requires Ogre Frame listener. Replaces a WHILE loop
	bool frameStarted(const Ogre::FrameEvent &evt);
	bool frameEnded(const Ogre::FrameEvent &evt);
};

#endif